package com.denso.workflow.admin.operation;

import com.denso.workflow.common.model.Operationlog;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

public class OperationlogService {

    private static final Operationlog dao = new Operationlog();

    /**
     * 分组统计某月管理员操作量
     * @param year
     * @param month
     * @return
     */
    public List<Record> countByDay(int year, int month, int day) {
        List<Record> countList = Db.find("select operator, count(id) as ct from operationlog where year(create_time)=? and month(create_time)=? and day(create_time)=? group by operator", year, month, day);
        return countList;
    }

    /**
     * 查看某月某管理员详细操作记录
     * @param year
     * @param month
     * @param operator
     * @return
     */
    public List<Operationlog> viewByDay(int year, int month, int day, String operator) {
        List<Operationlog> operationlogList = dao.find("select * from operationlog where year(create_time)=? and month(create_time)=? and day(create_time)=? and operator=? order by create_time", year, month, day, operator);
        return operationlogList;
    }

    public boolean save(Operationlog operationlog) {
        return operationlog.save();
    }

}
